#include "MoveTool.h"

MoveTool::MoveTool (QWidget *parent) : AbstractTool (parent)
{
  setText (tr("Move"));
}

MoveTool::~MoveTool ()
{

}



void MoveTool::_canvasMousePressedEvent (QPoint loc, QMouseEvent * event)
{
  if (event->buttons () == Qt::LeftButton)
  {
    _startPoint = event->pos ();
    _startCenter = __pWork->getViewportCtrl ()->getViewportTranslate ();
  }
}



void MoveTool::_canvasMouseMovedEvent (QPoint loc, QMouseEvent * event)
{
  if (event->buttons () == Qt::LeftButton)
  {
    QPoint v = event->pos () - _startPoint;
    //setText (QString::number (v.x ()));
    __pWork->getViewportCtrl ()->viewportMoveTo (_startCenter - v);
  }
}